#ifndef _MTM_EX1_H /* So that we won't include twice... */
#define _MTM_EX1_H

#include <stdio.h>

/* 
 * File name: mtm_ex1.h 
 * Writer: Li-Tal Mashiach (MATAM course staff, Winter 2007-2008)
 * Last update: 11 November 2007
 *
 * Description:
 * This files contains the supplementary functions to be used in ex1.
 *
 * Functions list:
 * mtm_error 			- prints error messages to stderr.
 * mtm_printMovie		- prints a movie's details (name, year, movie type, and number of users).
 * mtm_printPlayList	- prints a playlist's details (name, number of songs, music type, and number of users).
 * mtm_printGame		- prints a game's details (name, start age, end age, and number of users).
 * mtm_printScore		- prints score of a game (player name and score)
 */

/* Maximum characters in an input line */
#define MAX_LEN 120 

/*
 * Enum: mtmErrors
 * Error values to be used with mtm_error
 */

typedef enum mtmErrors_t
{
	err_OutOfMemory,		/* out of memory (after this error, you should abort the program) */
	err_WrongArguments,		/* program (main) called with wrong parameters (after this, you should abort the program) */
	err_OpenFailed,			/* failed to open file (after this, you should abort the program) */
	err_CloseFailed,		/* failed to close file (after this, you should abort the program) */
	err_WrongReport,		/* Second filed of Report command is not one of: MostPopular, BestPlayer, or NotUsed */
	err_WrongAppType,		/* illegal value in ApplicationType field (different than: Movie, PlayList, or Game) */
	err_AppExists,			/* Application name already exists */
	err_AppNotExists,		/* Application does not exists */
	err_WrongYear,			/* Year is not bigger than zero */
	err_WrongType,			/* illegal value in MovieType or MusicType fields */
	err_WrongNumOfSongs,	/* NumberOfSongs is not bigger than zero */
	err_WrongAge,			/* illegal StratAge or EndAge */
	err_WrongNumOfUsers,	/* NumberOfUsers is not bigger or equal to zero */
	err_WrongScore, 		/* Score is not bigger or equal to zero */
	err_WrongN,			    /* Number of most popular or best player in Report (N) is not bigger than zero */
	no_err				    /* in case no error has occured */
} mtmErrors;

/*
 * Name: mtm_error
 *
 * Arguments: 
 * ErrorCode   - error code, of type mtmErrors (see above).
 * 
 * Return value: none
 *
 * Description: Prints error message to stderr
 * if the value passed is "no_err", does nothing
 *
 */
void mtm_error(mtmErrors errorCode);

/*
 * Name: mtm_printMovie
 *
 * Arguments: 
 * Outstream   	- a pointer to the output stream
 * MovieName	- name of the movie
 * Year			- Year of the movie
 * MovieType	- type of the movie
 * NumOfUsers	- number of users that watched this movie
 * 
 * Return value: 1 if printing was successful, else 0
 *
 * Description: Prints movie's details: name of movie, year, type, and number of users
 *
 */
int mtm_printMovie(FILE* Outstream, const char* MovieName, 
				   int Year, const char* MovieType, int NumOfUsers);

/*
 * Name: mtm_printPlayList
 *
 * Arguments: 
 * Outstream   	- a pointer to the output stream
 * PlayListName	- name of the playlist
 * NumOfSongs	- number of songs in playlist
 * PlayListType	- type of the playlist
 * NumOfUsers	- number of users that listened to this playlist
 *
 * Return value: 1 if printing was successful, else 0
 *
 * Description: Prints play-list's details: name of play list, number of songs, 
 * type of music, and number of users
 *
 */
int mtm_printPlayList(FILE* Outstream, const char* PlayListName, 
				   int NumOfSongs, const char* PlayListType, int NumOfUsers);

/*
 * Name: mtm_printGame
 *
 * Arguments: 
 * Outstream   	- a pointer to the output stream
 * GameName		- name of the playlist
 * StartAge		- starting age for this game
 * EndAge		- ending age for this game
 * NumOfUsers	- number of users that played this game
 *
 * Return value: 1 if printing was successful, else 0
 *
 * Description: Prints game's details: name of the game, strat age and end age for the game, 
 * and number of users
 *
 */
int mtm_printGame(FILE* Outstream, const char* GameName, 
				   int StartAge, int EndAge, int NumOfUsers);

/*
 * Name: mtm_printProductSale
 *
 * Arguments: 
 * Outstream   	- a pointer to the output stream
 * PlayerName	- name of player
 * Score	- score of player
 *
 * Return value: 1 if printing was successful, else 0
 *
 * Description: Prints player name and score
 *
 */
int mtm_printScore(FILE* Outstream, const char* PlayerName, int Score);

#endif /* #ifndef _MTM_EX1_H */

